{extend name="common:frm_base" /}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" action="{:url('Config/handle')}" lay-filter="component-form-group">
                <div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
                    <ul class="layui-tab-title">
                        <li class="layui-this">系统设置</li>
                        <!--<li class="">用户管理</li>-->
                    </ul>
                    <div class="layui-tab-content">

                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">LOGO</label>
                                <div class="layui-input-block" style="display:flex;">
                                    <div style="width:100px;height:100px;border:1px solid #e0e0e0;">
                                        <img id="bus_img_btn" style="width:100px;height:100px;" src="{if $info['base']['img_url']['value']}{$info['base']['img_url']['value']}{else /}/add.jpg{/if}">
                                    </div>
                                    <input type="hidden" value="{$info['base']['img_url']['value']|default=''}" id="thumb" name="base[img_url][value]">
                                    <input value="{$info['base']['img_url']['id']|default=''}" type="hidden" name="base[img_url][id]">
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">积分比例</label>
                                <div class="layui-input-block">
                                    <input onkeyup="value=value.replace(/[^\d\.]/g,'')" type="text" value="{$info['base']['sys_name']['value']|default=''}" name="base[sys_name][value]" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                                    <input type="hidden" value="{$info['base']['sys_name']['id']|default=''}" name="base[sys_name][id]" />
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">签到</label>
                                <div class="layui-input-block">
                                    <input onkeyup="value=value.replace(/[^\d\.]/g,'')" type="text" value="{$info['base']['sign_in']['value']|default=''}" name="base[sign_in][value]" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                                    <input type="hidden" value="{$info['base']['sign_in']['id']|default=''}" name="base[sign_in][id]" />
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">资费说明</label>
                                <div class="layui-input-block">
                                    <input type="text" value="{$info['base']['descript']['value']|default=''}" name="base[descript][value]" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                                    <input type="hidden" value="{$info['base']['descript']['id']|default=''}" name="base[descript][id]" />
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">志愿者积分</label>
                                <div class="layui-input-inline">
                                    <input type="text" value="{$info['base']['duration1']['value']|default=''}" name="base[duration1][value]" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                                    <input type="hidden" value="{$info['base']['duration1']['id']|default=''}" name="base[duration1][id]" />
                                </div>
                                <div style="line-height:34px;" class="layui-input-inline">(志愿者时长*X)</div>
                            </div>
                        </div>
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">群众积分</label>
                                <div class="layui-input-inline">
                                    <input type="text" value="{$info['base']['duration2']['value']|default=''}" name="base[duration2][value]" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                                    <input type="hidden" value="{$info['base']['duration2']['id']|default=''}" name="base[duration2][id]" />
                                </div>
                                <div style="line-height:34px;" class="layui-input-inline">(群众时长*X)</div>
                            </div>
                        </div>

                        <!--<div class="layui-tab-item">内容2</div>-->
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formSub">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>


    layui.config({
        base: '__LAYUIADMIN__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate', 'upload'], function () {
        var $ = layui.$
            , form = layui.form
            ,upload = layui.upload
            , table = layui.table;


        form.on('submit(formSub)', function(data){
            console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
            console.log(data.form.action) //被执行提交的form对象，一般在存在form标签时才会返回
            console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            var param = data.field;
            $.ajax({
                type: 'POST'
                ,url: data.form.action
                ,data: param
                ,dataType: 'json'
                ,success:function(res){
                    if (res.code == 0){
                        layer.alert("提交成功");
                    } else{
                        layer.alert(res.msg);
                    }
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#bus_img_btn'
            , url: "{:url('common/upload_img')}"
            , data: {name:'ad'}
            , accept: 'images'
            , acceptMime: 'image/*,image/gif'
            , done: function (res) {
                $('#bus_img_btn').attr('src',res.data.img);
                $('#thumb').val(res.data.img);
            }
            , error: function () {
            }
        });
    });
</script>
</body>
</html>
{/block}
